<?php
/**
 * files_browse.inc
 * Browse/upload files.
 * @copyright	Copyright(c) 2002-2010 Bjorn Winberg
 * @author		Bjorn Winberg <cms@anomalye.net>
 * @license		http://www.gnu.org/licenses/gpl.html GNU General Public License version 2
 * @package		AnomalyWiki
 */
	$this->mSystem->mHtmlHeaders[] = '<link type="text/css" href="' . $this->getSkinUrl('files_browse.css') . '" rel="stylesheet" />';
?>
<h1><?php echo $this->localString('FB_TITLE');?></h1>
<?php
	echo $this->generateMenu('files', 'MENU', 'subMenu');
?>
<div class="helpBox">
	<?php echo $this->localString('FB_HELP');?>
</div>

<div class="section">
<?php
	$style = false;
	echo '<div class="sectionHeader">';
	echo  $aParams['pathString'];
	
	echo '<div class="browseUploadButton">';
	echo '<form class="" id="files_createDir" action="' . $this->generateUrl('files', array('a' => 'create_dir', 'dir' => $aParams['dir'])) . '" method="post">';
	echo '<input type="text" id="name" name="name" value="' . (isset($aParams['name'])? $this->getSafeStr($aParams['name']): '') . '" maxlength="' . Files::PARAM_MAX_DIR . '" />';
	echo '<div class="browseUploadButton">';
	echo '<input type="submit" name="submit" value="' . $this->localString('FB_CREATEDIR_SUBMIT') . '" />';
	echo '</div>';
	echo '</form>';
	echo '</div>';
	
	echo '</div>';
	
	if($aParams['parent'] !== ''){
		echo '<div class="sectionRow2">';
		echo '<div class="browseCol browseColName"><a href="' . $this->generateUrl('files', array('dir' => $aParams['parent'])) . '">'. $this->localString('FB_PARENTMARKER') . '</a></div>';
		echo '</div>';
	}
	foreach($aParams['dirList'] as $item){ 
		$style = $style == 'sectionRow1'? 'sectionRow2': 'sectionRow1';
		echo '<div class="' . $style . '">';
		echo '<div class="browseCol browseColName">' . $this->localString('FB_DIRMARKER') . '<a href="' . $this->generateUrl('files', array('dir' => $item['id'])) . '">'. $this->getSafeStr($item['name']) . '</a></div>';
		echo '</div>';
	}
	foreach($aParams['fileList'] as $item){ 
		$style = $style == 'sectionRow1'? 'sectionRow2': 'sectionRow1';
		echo '<div class="' . $style . '">';
		echo '<div class="browseCol browseColName">' . '<a href="' . $this->generateUrl('files', array('dir' => $item['directory_id'], 'file' => $item['id'])) . '">'. $this->getSafeStr($item['name']) . '</a></div>';
		echo '</div>';
	}
?>
</div>


<div class="section">
<?php
	if($this->requireAuthorization('FILES/UPLOAD')){
		echo '<div class="sectionHeader">';
		echo  $this->localString('FB_UPLOAD');
		echo '</div>';
	
		$maxSizeMB = $this->getUploadSize() / 1000000;
					
		echo  '<div class="sectionRow2">';
		echo '<form class="" enctype="multipart/form-data" action="' . $this->generateUrl('files', array('a' => 'upload', 'dir' => $aParams['dir'])) . '" method="post" id="files_uploadForm">';
		echo '<input type="file" name="userfile" id="userfile" />';
		echo '<div class="browseUploadButton">';
		echo $this->localString('FB_UPLOAD_FILE', array($maxSizeMB));
		echo '<input type="hidden" name="MAX_FILE_SIZE" id="MAX_FILE_SIZE" value="' . $this->getUploadSize() . '" />';
		echo '<input type="submit" name="submit" value="' . $this->localString('FB_UPLOAD_SUBMIT') . '" />';
		echo '</div>';
		echo '</form>';
		echo '</div>';
		
		
		
		

	}
?>
</div>
